#!/usr/bin/python3.5

# -*- coding: utf-8 -*-




# def two(l, r, target):
#     i = 0
#     while l <= r:
#         mid = (l + r) / 2
#         i += 1
#         if a[mid] == target:
#             print(i)
#             return True
#         else:
#             if a[mid] > target:
#                 r = mid - 1
#             else:
#                 l = mid + 1
#     return False
#
# print(two(0, n - 1, target))



def binary_search(arr,target):
    k=0
    l=0
    r = len(arr)
    if arr[l]==target or arr[r-1]==target:
          return True
    while r>l:
        mid = (r+l)//2
        k+=1
        if arr[mid]==target:
            print(k)
            return True
        elif arr[mid]>target:
            r = mid
        else:
            l = mid+1
    return False



if __name__ == "__main__":
    n = 100
    a = [i for i in range(n)]
    target = 41
    print(binary_search(a,target))
